#include <STC/STC89C5xRC.H>
#include <intrins.h>

#define uint unsigned int
#define uchar unsigned char

sbit beep = P2 ^ 3; // 蜂鸣器

/**
 * 毫秒级延时
 * 12T
 * Fosc = 11.0592 MHz
 * @param ms 延时毫秒数，设定的取值范围：0~65535
 */
void delay(uint ms)
{
	uint x, y;
	for (x = ms; x > 0; x--)
		for (y = 114; y > 0; y--)
			;
}

/**
 * 板子有源蜂鸣器报警，4位LED移动点亮
 */
void main()
{
	uchar temp = 0xf0;

	P1 = temp; // 初始化，点亮4个灯，1111 0000(2)
	delay(100);
	while (1)
	{
		temp = _crol_(temp, 1);
		P1 = temp;
		beep = ~beep; // 蜂鸣器发出嘀声
		delay(100);
	}
}
